package com.jiazhong.spring.ioc.mybatis.mapper;

import com.jiazhong.commons.bean.Emp;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface EmpMapper {

    @Select("select * from emp where state=1")
    List<Emp> findAll();

    @Select("select * from emp where state=1 and ename like #{ename}")
    List<Emp> findByEname(String ename);

    @Select("select * from emp where state=1 and empno=#{id}")
    Emp findById(int id);

    @Insert("insert into emp values(null,#{ename},#{job},#{mgr},now(),#{sal},#{comm},#{deptNo},1) ")
    int save(Emp emp);

    @Delete("update emp set state=0 where empno=#{id} and state=1")
    int removeById(int id);

    @Update("update emp set ename=#{ename},job=#{job},mgr=#{mgr},sal=#{sal},comm=#{comm},deptno=#{deptNo} where empno=#{empNo} and state=1")
    int update(Emp emp);
}
